# -*- makefile -*-
# rules.conf
#	- used to build debian/control and debian/rules.parameters
#	- assumes unpacked sources

include debian/rules.defs
include debian/rules.sonames

# Helper to generate biarch/triarch dependencies.
# For example, $(eval $(call gen_multilib_deps,gomp)) will create the
# libgompbiarch variable, and make it contains the libgompbiarch{32,64,n32}
# variables if biarch{32,64,n32} is set to yes.
define gen_multilib_deps
  lib$1biarch64	:= lib64$1$$($(shell echo $1 | tr "a-z" "A-Z")_SONAME) (>= $$$${gcc:Version})
  lib$1biarch32	:= lib32$1$$($(shell echo $1 | tr "a-z" "A-Z")_SONAME) (>= $$$${gcc:Version})
  lib$1biarchn32 := libn32$1$$($(shell echo $1 | tr "a-z" "A-Z")_SONAME) (>= $$$${gcc:Version})
  ifeq ($$(biarch64),yes)
    lib$1biarch := $$(lib$1biarch64)
  endif
  ifeq ($$(biarch32),yes)
    lib$1biarch := $$(lib$1biarch32)
  endif
  ifeq ($$(biarchn32),yes)
    ifeq ($$(biarch64),yes)
      lib$1biarch := $$(lib$1biarch64), $$(lib$1biarchn32)
    else
      lib$1biarch := $$(lib$1biarchn32)
    endif
  endif
endef
$(foreach x,gomp mudflap ssp gfortran objc,$(eval $(call gen_multilib_deps,$(x))))

# Helper to generate _no_archs variables.
# For example, $(eval $(call gen_no_archs,java)) will create the java_no_archs
# variable, using the java_no_cpu and java_no_systems variables.
define gen_no_archs
  $1_no_archs :=
  ifneq (,$$($1_no_cpus))
    $1_no_archs += $$(foreach cpu,$$(filter-out i386 amd64 alpha arm,$$($1_no_cpus)),!$$(cpu))
    ifneq (,$$(filter i386,$$($1_no_cpus)))
      $1_no_archs += !i386 !hurd-i386 !kfreebsd-i386 !knetbsd-i386
    endif
    ifneq (,$$(filter amd64,$$($1_no_cpus)))
      $1_no_archs += !amd64 !kfreebsd-amd64
    endif
    ifneq (,$$(filter alpha,$$($1_no_cpus)))
      $1_no_archs += !alpha !hurd-alpha !knetbsd-alpha
    endif
    ifneq (,$$(filter arm,$$($1_no_cpus)))
      $1_no_archs += !arm !armel
    endif
    ifneq (,$$(strip $3))
      $1_no_systems_tmp := $$(subst $$(SPACE)gnu$$(SPACE),$$(SPACE)hurd-gnu$$(SPACE),$$(SPACE)$3$$(SPACE))
      $1_no_archs += $$(foreach cpu,$$($1_no_cpus),$$(foreach system,$$($1_no_systems_tmp),!$$(subst gnu,$$(cpu),$$(system))))
    endif
  endif
  ifneq (,$$($1_no_systems))
    $1_no_systems_tmp := $$(subst $$(SPACE)gnu$$(SPACE),$$(SPACE)hurd-gnu$$(SPACE),$$(SPACE)$$($1_no_systems)$$(SPACE))
    $1_no_archs += $$(foreach system,$$($1_no_systems_tmp),$$(foreach cpu,$2,!$$(subst gnu,$$(cpu),$$(system))))
  endif
  $1_no_archs := $$(strip $$($1_no_archs))
endef
base_deb_cpus := i386 alpha
base_deb_systems :=
$(foreach x,ada java java_plugin pascal fortran libphobos libgc check locale,$(eval $(call gen_no_archs,$(x),$(base_deb_cpus),$(base_deb_systems))))
linux_no_archs := !hurd-i386 !hurd-alpha !kfreebsd-i386 !kfreebsd-amd64 !knetbsd-i386 !knetbsd-alpha

GCC_VERSION := $(strip $(shell cat $(srcdir)/gcc/BASE-VER))
NEXT_GCC_VERSION := $(shell echo $(GCC_VERSION) | \
	awk -F. '{OFS="."; if (NF==2) $$3=1; else $$NF += 1; print}')
GCC_MAJOR_VERSION := $(shell echo $(GCC_VERSION)   | sed -r 's/([0-9])\.[0-9]\.[0-9]/\1/')
GCC_MINOR_VERSION := $(shell echo $(GCC_VERSION)   | sed -r 's/[0-9]\.([0-9])\.[0-9]/\1/')
GCC_RELEASE_VERSION := $(shell echo $(GCC_VERSION) | sed -r 's/[0-9]\.[0-9]\.([0-9])/\1/')
NEXT_GCC_MAJOR_VERSION := $(shell expr $(echo $(GCC_MAJOR_VERSION)) + 1)
NEXT_GCC_MINOR_VERSION := $(shell expr $(echo $(GCC_MINOR_VERSION)) + 1)
NEXT_GCC_RELEASE_VERSION := $(shell expr $(echo $(GCC_MAJOR_VERSION)) + 1)

GCC_SOURCE_VERSION := $(shell echo $(DEB_VERSION) | sed 's/-.*//')
NEXT_GCC_SOURCE_VERSION := $(shell echo $(GCC_SOURCE_VERSION) | \
	awk -F. '{OFS="."; if (NF==2) $$3=1; else $$NF += 1; print}')

ifeq ($(PKGSOURCE),gcc-snapshot)
  BASE_VERSION := $(shell echo $(GCC_VERSION) | sed -e 's/\([1-9]\.[0-9]\).*/\1/')
endif
ifneq (,$(findstring gpc,$(PKGSOURCE)))
  GPC_BASE_VERSION := $(word 1, $(subst -, ,$(DEB_VERSION)))
  DEB_VERSION := $(subst $(GPC_BASE_VERSION)-,,$(DEB_VERSION))
endif
ifneq (,$(findstring gdc,$(PKGSOURCE)))
  GDC_BASE_VERSION := $(word 1, $(subst -, ,$(DEB_VERSION)))
  DEB_VERSION := $(shell echo $(DEB_VERSION) | sed -r 's/[0-9]{8}-//')
  DEB_VERSION := $(subst $(GDC_BASE_VERSION)-,,$(DEB_VERSION))
endif

MAINTAINER = maemo integration <integration@maemo.org>
ifeq ($(distribution),Ubuntu)
  ifneq (,$(findstring $(PKGSOURCE),gnat gpc gdc))
    MAINTAINER = Ubuntu MOTU Developers <ubuntu-motu@lists.ubuntu.com>
  else
    MAINTAINER = Ubuntu Core developers <ubuntu-devel-discuss@lists.ubuntu.com>
  endif
endif

UPLOADERS = maemo integration <integration@maemo.org>

DPKG_BUILD_DEP = dpkg-dev (>= 1.14.15)
ifeq ($(DEB_CROSS),yes)
  DPKG_BUILD_DEP +=, dpkg-cross (>= 1.25.99)
endif

# The binutils version needed.
# The oldest suitable versions for the various platforms can be found in
# INSTALL/specific.html ; we take a tighter dependency if possible to be on
# the safe side (something like newest( version in stable, versions for the
# various platforms in INSTALL/specific.html) ).
# We need binutils (>= 2.19.1) for a new dwarf unwind expression opcode.
# See http://gcc.gnu.org/ml/gcc-patches/2008-09/msg01713.html
BINUTILSV      = 2.19
ifeq ($(DEB_CROSS),yes)
  BINUTILS_BUILD_DEP = binutils$(TS) (>= $(BINUTILSV))
else
  BINUTILS_BUILD_DEP = binutils (>= $(BINUTILSV)) | binutils-multiarch (>= $(BINUTILSV))
endif
ifneq (,$(findstring snapshot,$(PKGSOURCE))$(findstring 4.5,$(PKGSOURCE)))
  BINUTILS_BUILD_DEP += , binutils-gold (>= $(BINUTILSV)) [$(gold_archs)]
endif

# libc-dev dependencies
libc_ver := 2.5
ifneq (,$(findstring gnat,$(PKGSOURCE)))
  libc_ver := 2.9-21
endif
ifeq ($(DEB_TARGET_ARCH_OS),linux)
  ifneq (,$(findstring $(DEB_TARGET_ARCH),alpha ia64))
    LIBC_DEP = libc6.1
  else
    LIBC_DEP = libc6
  endif
else
  ifeq ($(DEB_TARGET_ARCH_OS),hurd)
    LIBC_DEP = libc0.3
  endif
  ifeq ($(DEB_TARGET_ARCH_OS),kfreebsd)
    LIBC_DEP = libc0.1
  endif
  ifeq ($(DEB_TARGET_ARCH),uclibc)
       LIBC_DEP ?= libuclibc
       LIBC_DEV_DEP ?= libuclibc-dev
  endif
endif
LIBC_DEV_DEP = $(LIBC_DEP)-dev
# for cross
ifeq ($(DEB_CROSS),yes)
  LIBC_DEP ?= $(LIBC_DEP)$(LS)
  LIBC_DEV_DEP ?= $(LIBC_DEV_DEP)$(LS)
endif

# this is about Debian archs name, *NOT* GNU target triplet
biarch_deb_map := \
	i386=amd64 amd64=i386 \
	mips=mips64 mipsel=mips64 \
	powerpc=ppc64 ppc64=powerpc \
	sparc=sparc64 \
	s390=s390x \
	kfreebsd-amd64=i386

biarch_deb_arch := $(patsubst $(DEB_TARGET_ARCH)=%,%, \
	$(filter $(DEB_TARGET_ARCH)=%,$(biarch_deb_map)))

LIBC_BIARCH_DEP :=
LIBC_BIARCH_DEV_DEP :=
LIBCXX_BIARCH_DEP :=
LIBCXX_BIARCH_DBG_DEP :=
ifneq (,$(findstring yes,$(biarch64) $(biarch32) $(biarchn32)))
  LIBC_BIARCH_DEP := $(LIBC_DEP)-$(biarch_deb_arch)$(LS) (>= $(libc_ver))
  LIBC_BIARCH_DEV_DEP := $(LIBC_DEV_DEP)-$(biarch_deb_arch)$(LS) (>= $(libc_ver))
  ifeq ($(biarch64),yes)
    LIBCXX_BIARCH_DEP := lib64stdc++$(CXX_SONAME)$(LS) (>= $${gcc:Version})
    LIBCXX_BIARCH_DBG_DEP := lib64stdc++$(CXX_SONAME)-$(BASE_VERSION)-dbg
  endif
  ifeq ($(biarch32),yes)
    LIBCXX_BIARCH_DEP := lib32stdc++$(CXX_SONAME)$(LS) (>= $${gcc:Version})
    LIBCXX_BIARCH_DBG_DEP := lib32stdc++$(CXX_SONAME)-$(BASE_VERSION)-dbg
  endif
  ifeq ($(biarchn32),yes)
    ifneq (,$(findstring $(DEB_TARGET_ARCH),mips mipsel))
      triarch :=
      ifeq ($(biarch64),yes)
        triarch := $(COMMA)$(SPACE)
      endif
      LIBC_BIARCH_DEV_DEP += $(triarch)libc6-dev-mipsn32$(LS) (>= $(libc_ver))
      LIBC_BIARCH_DEP += $(triarch)libc6-mipsn32$(LS) (>= $(libc_ver))
      LIBCXX_BIARCH_DEP += $(triarch)libn32stdc++$(CXX_SONAME)$(LS) (>= $${gcc:Version})
      LIBCXX_BIARCH_DBG_DEP += $(triarch)libn32stdc++$(CXX_SONAME)-$(BASE_VERSION)-dbg
    endif
  endif
endif

# Add suffix and required version
LIBC_DEV_DEP := $(LIBC_DEV_DEP)$(LS) (>= $(libc_ver))

# TODO: make this automatic, there must be a better way to define LIBC_DEP.
ifneq ($(DEB_CROSS),yes)
  LIBC_BUILD_DEP = libc6.1-dev (>= $(libc_ver)) [alpha ia64] | libc0.3-dev (>= $(libc_ver)) [hurd-i386] | libc0.1-dev (>= $(libc_ver)) [kfreebsd-i386 kfreebsd-amd64] | libc6-dev (>= $(libc_ver)),
  LIBC_BIARCH_BUILD_DEP = libc6-dev-sparc64 [sparc], libc6-dev-s390x [s390], libc6-dev-i386 [amd64], libc6-dev-powerpc [ppc64], libc6-dev-ppc64 [powerpc], libc0.1-dev-i386 [kfreebsd-amd64], lib32gcc1 [amd64 ppc64 kfreebsd-amd64], lib64gcc1 [powerpc sparc s390], libc6-dev-mips64 [mips mipsel], libc6-dev-mipsn32 [mips mipsel],
else
  LIBC_BUILD_DEP = $(LIBC_DEV_DEP),
  ifneq ($(LIBC_BIARCH_DEV_DEP),)
    LIBC_BIARCH_BUILD_DEP = $(LIBC_BIARCH_DEV_DEP),
  else
    LIBC_BIARCH_BUILD_DEP =
  endif
endif

GCC_MULTILIB_BUILD_DEP = gcc-multilib [$(multilib_archs)],

LIBUNWIND_DEV_DEP := libunwind7-dev$(LS) (>= 0.98.5-6)
LIBUNWIND_BUILD_DEP := $(LIBUNWIND_DEV_DEP) [ia64],
LIBATOMIC_OPS_BUILD_DEP := libatomic-ops-dev$(LS) [ia64],
ifneq ($(DEB_TARGET_ARCH),ia64)
  LIBUNWIND_DEV_DEP := # nothing
endif

GMP_BUILD_DEP = libgmp3-dev,
MPFR_BUILD_DEP = libmpfr-dev,

PPL_BUILD_DEP = libppl-dev (>= 0.10) | libppl0.10-dev (>= 0.10),
CLOOG_BUILD_DEP = libcloog-ppl-dev (>= 0.15),
CLOOG_RUNTIME_DEP = libcloog-ppl0, libppl-c2, libppl7
# FIXME GCC-4.5
ifneq (,$(findstring snapshot,$(PKGSOURCE)))
  MPC_BUILD_DEP = libmpc-dev,
  ELF_BUILD_DEP = libelfg0-dev (>= 0.8.12),
endif
ifneq (,$(findstring 4.5,$(PKGSOURCE)))
  MPC_BUILD_DEP = libmpc-dev,
  ELF_BUILD_DEP = libelfg0-dev (>= 0.8.12),
endif

SOURCE_BUILD_DEP :=
ifeq (,$(findstring gcc,$(PKGSOURCE)))
  SOURCE_BUILD_DEP := gcc-$(BASE_VERSION)-source (>= $(GCC_SOURCE_VERSION)), gcc-$(BASE_VERSION)-source (<< $(NEXT_GCC_SOURCE_VERSION)),
endif

CHECK_BUILD_DEP :=
#CHECK_BUILD_DEP := dejagnu [$(check_no_archs)],
#ifneq (,$(findstring gcc,$(PKGSOURCE)))
#  CHECK_BUILD_DEP += autogen,
#endif

AUTO_BUILD_DEP := m4, libtool,
ifneq (,$(findstring 4.4,$(PKGSOURCE)))
  AUTO_BUILD_DEP += autoconf2.59, automake1.9,
else ifneq (,$(findstring 4.5,$(PKGSOURCE)))
  AUTO_BUILD_DEP += autoconf (>= 2.64), autoconf (<< 2.65), automake (>= 1:1.11), automake (<< 1:1.12),
else ifeq ($(PKGSOURCE),gcc-snapshot)
  AUTO_BUILD_DEP += autoconf (>= 2.64), autoconf (<< 2.65), automake (>= 1:1.11), automake (<< 1:1.12),
endif

ifneq ($(DEB_CROSS),yes)
LIBC_BUILD_DEP := libc6.1-dev (>= $(libc_ver)) [alpha ia64] | libc0.3-dev (>= $(libc_ver)) [hurd-i386] | libc0.1-dev (>= $(libc_ver)) [kfreebsd-i386 kfreebsd-amd64] | libc6-dev (>= $(libc_ver))
JAVA_BUILD_DEP := zlib1g-dev, libantlr-java,

ifeq ($(PKGSOURCE),gcj-$(BASE_VERSION))
  bd_java_archs =
else ifeq ($(PKGSOURCE)-$(with_java),gcc-snapshot-yes)
  bd_java_archs =
else
  bd_java_archs = $(EMPTY) [$(java_no_archs)]
endif

ifneq (,$(java_awt_peers))
  JAVA_BUILD_DEP += fastjar$(bd_java_archs), libmagic-dev$(bd_java_archs),
  JAVA_BUILD_DEP += libecj-java (>= 3.3.0-2)$(bd_java_archs), zip$(bd_java_archs),
  ifeq ($(with_java_maintainer_mode),yes)
    # gcj-4.3 needed for gjavah-4.3.
    JAVA_BUILD_DEP += gcj-4.4$(bd_java_archs), ecj (>= 3.3.0-2)$(bd_java_archs),
  endif
  JAVA_BUILD_DEP += libasound2-dev [$(java_no_archs) $(linux_no_archs)],
  ifneq (,$(findstring gtk,$(java_awt_peers)))
    JAVA_BUILD_DEP += libxtst-dev$(bd_java_archs), libxt-dev$(bd_java_archs), libgtk2.0-dev (>= 2.4.4-2)$(bd_java_archs), libart-2.0-dev$(bd_java_archs), libcairo2-dev$(bd_java_archs),
  endif
  ifneq (,$(findstring qt,$(java_awt_peers)))
    JAVA_BUILD_DEP += libqt4-dev (>= 4.1.0)$(bd_java_archs),
  endif
  # gconf peer, disabled by default
  #JAVA_BUILD_DEP += libgconf2-dev$(bd_java_archs),
  # gstreamer peer
  #JAVA_BUILD_DEP += libgstreamer-plugins-base0.10-dev$(bd_java_archs),
  ifneq ($(PKGSOURCE),gcc-snapshot)
    JAVA_BUILD_DEP += g++-4.4 [armel],
  endif
endif
ifneq ($(with_standalone_gcj),yes)
  ifeq ($(PKGSOURCE),gcj-$(BASE_VERSION))
    JAVA_BUILD_DEP += $(SOURCE_BUILD_DEP)
  endif
endif
#JAVA_BUILD_INDEP := gcj-$(BASE_VERSION)-jdk
ifeq ($(PKGSOURCE),gcc-snapshot)
  LIBSTDCXX_BUILD_INDEP = doxygen (>= 1.5.4), graphviz (>= 2.2), texlive-latex-base
  JAVA_BUILD_INDEP :=
endif
ifeq ($(with_separate_libgcj),yes)
  ifeq ($(PKGSOURCE),gcc-$(BASE_VERSION))
    JAVA_BUILD_DEP :=
    JAVA_BUILD_INDEP :=
  endif
endif

ECJ_DEP = ecj, libecj-java (>= 3.3.0-2)
ECJ_DEP = ecj-gcj, libecj-java-gcj (>= 3.3.0-2)
ifneq (,$(filter $(DEB_HOST_ARCH),arm armel))
  ECJ_DEP +=, ecj1
endif

ifeq ($(PKGSOURCE),gcc-$(BASE_VERSION))
  LIBSTDCXX_BUILD_INDEP = doxygen (>= 1.4.2), graphviz (>= 2.2), texlive-latex-base
  JAVA_BUILD_INDEP :=, $(JAVA_BUILD_INDEP)
endif

PASCAL_BUILD_DEP := libncurses5-dev [pascal_no_archs], texlive-latex-base [pascal_no_archs], libgmp3-dev [pascal_no_archs], help2man [pascal_no_archs],

SPU_BUILD_DEP := binutils-spu (>= $(BINUTILSV)) [powerpc ppc64], newlib-spu (>= 1.16.0) [powerpc ppc64], gcc-$(BASE_VERSION)-base [powerpc ppc64],
SPU_BUILD_DEP := binutils-spu (>= $(BINUTILSV)) [powerpc ppc64], newlib-spu (>= 1.16.0) [powerpc ppc64],

ifeq ($(PKGSOURCE),gcc-$(BASE_VERSION))
  ifneq ($(with_separate_gnat),yes)
    # Build gnat as part of the combiled gcc-x.y source package.  Do not fail
    # if gnat is not present on unsupported architectures; the build scripts
    # will not use gnat anyway.
    GNAT_BUILD_DEP := gnat (>= 4.1) [$(ada_no_archs)],
  endif
  ifeq ($(with_separate_gpc),yes)
    PASCAL_BUILD_DEP :=
  endif
else ifeq ($(PKGSOURCE),gcc-snapshot)
  # Ditto, as part of the gcc-snapshot package.
  # FIXME: ad hoc dependency, better fix setting of ada_no_archs
  #GNAT_BUILD_DEP := gnat (>= 4.1) [$(ada_no_archs)], gcc-snapshot (>= 20090821-1) [armel],
  GNAT_BUILD_DEP := gnat (>= 4.1) [!arm !armel !m68k !hurd-i386], gcc-snapshot (>= 20100116-1) [armel],
  PASCAL_BUILD_DEP :=
else ifeq ($(PKGSOURCE),gnat-$(BASE_VERSION))
  # Special source package just for gnat. Fail early if gnat is not present,
  # rather than waste CPU cycles and fail later.
  GNAT_BUILD_DEP := gnat (>= 4.1) [!armel], gcc-snapshot (>= 20100116-1) [armel],
  GNAT_BUILD_DEP += $(SOURCE_BUILD_DEP)
  JAVA_BUILD_DEP :=
  JAVA_BUILD_INDEP :=
  PASCAL_BUILD_DEP :=
  # gnat on spu should work ...
  SPU_BUILD_DEP :=
else ifeq ($(PKGSOURCE),gcj-$(BASE_VERSION))
  # Special source package just for gcj.
  GNAT_BUILD_DEP :=
  PASCAL_BUILD_DEP :=
  GDC_BUILD_DEP :=
  SPU_BUILD_DEP :=
else ifeq ($(PKGSOURCE),gdc-$(BASE_VERSION))
  # Special source package just for gdc.
  GNAT_BUILD_DEP :=
  JAVA_BUILD_DEP :=
  JAVA_BUILD_INDEP :=
  PASCAL_BUILD_DEP :=
  GDC_BUILD_DEP := $(SOURCE_BUILD_DEP)
  SPU_BUILD_DEP :=
else ifeq ($(PKGSOURCE),gpc-$(BASE_VERSION))
  # Special source package just for gpc.
  GNAT_BUILD_DEP :=
  JAVA_BUILD_DEP :=
  JAVA_BUILD_INDEP :=
  GDC_BUILD_DEP :=
  PASCAL_BUILD_DEP += $(SOURCE_BUILD_DEP)
  SPU_BUILD_DEP :=
endif

else
# build cross compiler
  CROSS_BUILD_DEP := libc6-dev$(cross_lib_arch), zlib1g-dev$(cross_lib_arch), libmpfr-dev$(cross_lib_arch),
  SOURCE_BUILD_DEP := gcc-$(BASE_VERSION)-source (>= $(GCC_VERSION)), gcc-$(BASE_VERSION)-source (<< $(NEXT_GCC_VERSION)),
  ifeq ($(with_java),yes)
    JAVA_BUILD_DEP := zlib1g-dev, lib64z1-dev [i386 powerpc sparc s390], lib32z1-dev [amd64 ppc64 kfreebsd-amd64],
  endif
  JAVA_BUILD_INDEP :=
  GNAT_BUILD_DEP :=
  ifeq (,$(findstring spu,$(DEB_TARGET_GNU_CPU)))
    SPU_BUILD_DEP :=
  endif
endif # cross compiler

# The numeric part of the gcc version number (x.yy.zz)
NEXT_GCC_VERSION := $(shell echo $(GCC_VERSION) | \
		awk -F. '{OFS="."; if (NF==2) $$3=1; else $$NF += 1; print}')
# first version with a new path component in gcc_lib_dir (i.e. GCC_VERSION
# or TARGET_ALIAS changes), or last version available for all architectures
DEB_GCC_SOFT_VERSION := 4.4.1-0
DEB_GCJ_SOFT_VERSION := 4.4.1-0
ifeq ($(with_pascal),yes)
GPC_DATE := $(shell sed -n 's/^.define GPC_VERSION_STRING "\(.*\)"/\1/p' $(srcdir)/gcc/p/version.h || true)
DEB_GPC_VERSION := $(shell echo $(DEB_VERSION) \
			   | sed 's/.*:\(.*\)-\(.*\)/2:\1.$(GPC_DATE)-\2/')
endif

ifeq ($(with_pascal),yes)
  DEB_GPC_VERSION := $(GPC_BASE_VERSION)-$(DEB_VERSION)
endif

ifeq ($(with_d),yes)
  DEB_GDC_VERSION := $(GDC_BASE_VERSION)-$(DEB_VERSION)
endif

# semiautomatic ...
DEB_SOVERSION		:= $(DEB_VERSION)
DEB_SOVERSION		:= 4.4
DEB_SOEVERSION		:= $(EPOCH):4.4
DEB_STDCXX_SOVERSION	:= 4.4
DEB_GCJ_SOVERSION	:= 4.4
DEB_GOMP_SOVERSION	:= $(DEB_SOVERSION)
DEB_GCCMATH_SOVERSION	:= $(DEB_SOVERSION)

DEB_GCC_VERSION := $(DEB_VERSION)
DEB_GCJ_VERSION := $(DEB_VERSION)
ifeq ($(with_separate_libgcj),yes)
  ifeq ($(PKGSOURCE),gcj-$(BASE_VERSION))
    DEB_GCC_VERSION := $(DEB_GCC_SOFT_VERSION)
  endif
endif

DEB_GNAT_VERSION := $(DEB_VERSION)
ifeq ($(with_separate_gnat),yes)
  ifeq ($(PKGSOURCE),gnat-$(BASE_VERSION))
    DEB_GCC_VERSION := $(DEB_GCC_SOFT_VERSION)
  endif
endif

# manual ...
ifeq ($(DEB_TARGET_GNU_CPU), $(findstring $(DEB_TARGET_GNU_CPU),hppa m68k))
  ifeq ($(DEB_TARGET_ARCH),m68k)
    GCC_SONAME := 2
  endif
  ifeq ($(DEB_TARGET_ARCH),hppa)
    GCC_SONAME := 4
  endif
  DEB_LIBGCC_SOVERSION := $(DEB_SOVERSION)
  DEB_LIBGCC_VERSION := $(DEB_VERSION)
else
  GCC_SONAME := 1
  DEB_LIBGCC_SOVERSION := $(DEB_SOEVERSION)
  DEB_LIBGCC_VERSION := $(DEB_EVERSION)
endif

LIBGCC_DEP := libgcc$(GCC_SONAME)$(LS) (>= $(DEB_LIBGCC_VERSION))
LIBGCC_BIARCH_DEP := 
ifeq ($(biarch64),yes)
  LIBGCC_BIARCH_DEP := lib64gcc$(GCC_SONAME)$(LS) (>= $(DEB_LIBGCC_VERSION))
endif
ifeq ($(biarch32),yes)
  LIBGCC_BIARCH_DEP := lib32gcc$(GCC_SONAME)$(LS) (>= $(DEB_LIBGCC_VERSION))
endif
ifeq ($(biarchn32),yes)
  ifeq ($(biarch64),yes)
    LIBGCC_BIARCH_DEP := lib64gcc$(GCC_SONAME)$(LS) (>= $(DEB_LIBGCC_VERSION)), libn32gcc$(GCC_SONAME)$(LS) (>= $(DEB_LIBGCC_VERSION))
  else
    LIBGCC_BIARCH_DEP := libn32gcc$(GCC_SONAME)$(LS) (>= $(DEB_LIBGCC_VERSION))
  endif
endif

GNAT_VERSION := $(BASE_VERSION)

LIBGNAT_DEP :=
ifeq ($(with_libgnat),yes)
  LIBGNAT_DEP := libgnat-$(GNAT_VERSION) (= $(DEB_VERSION))
endif

pkg_ver := -$(BASE_VERSION)

PKG_GCJ_EXT = $(GCJ_SONAME1)
PKG_LIBGCJ_EXT = $(GCJ_SONAME1)$(if $(GCJ_SONAME2),-$(GCJ_SONAME2))

ctrl_flags = \
	-DBINUTILSV=$(BINUTILSV) \
	-DSRCNAME=$(PKGSOURCE) \
	-D__$(DEB_TARGET_GNU_CPU)__ \
	-DARCH=$(DEB_TARGET_ARCH) \
	-DDIST=$(distribution)

ctrl_flags += \
	-DLIBC_DEV_DEP="$(LIBC_DEV_DEP)" \
	-DLIBC_BIARCH_BUILD_DEP="$(LIBC_BIARCH_BUILD_DEP)" \
	-DFORTRAN_BUILD_DEP="$(FORTRAN_BUILD_DEP)" \
	-DGNAT_BUILD_DEP="$(GNAT_BUILD_DEP)" \
	-DJAVA_BUILD_DEP="$(JAVA_BUILD_DEP)" \
	-DJAVA_BUILD_INDEP="$(JAVA_BUILD_INDEP)" \
	-DLIBSTDCXX_BUILD_INDEP="$(LIBSTDCXX_BUILD_INDEP)" \
	-DPASCAL_BUILD_DEP="$(PASCAL_BUILD_DEP)" \
	-DGDC_BUILD_DEP="$(GDC_BUILD_DEP)" \
	-DSPU_BUILD_DEP="$(SPU_BUILD_DEP)" \
	-DBINUTILS_BUILD_DEP="$(BINUTILS_BUILD_DEP)" \
	-DLIBC_BUILD_DEP="$(LIBC_BUILD_DEP)" \
	-DCHECK_BUILD_DEP="$(CHECK_BUILD_DEP)" \
	-DAUTO_BUILD_DEP="$(AUTO_BUILD_DEP)" \
	-DAUTOGEN_BUILD_DEP="$(AUTOGEN_BUILD_DEP)" \
	-DCLOOG_BUILD_DEP="$(CLOOG_BUILD_DEP)" \
	-DMPC_BUILD_DEP="$(MPC_BUILD_DEP)" \
	-DELF_BUILD_DEP="$(ELF_BUILD_DEP)" \
	-DSOURCE_BUILD_DEP="$(SOURCE_BUILD_DEP)" \
	-DCROSS_BUILD_DEP="$(CROSS_BUILD_DEP)" \
	-DMULTILIB_ARCHS="$(multilib_archs)" \
	-DNEON_ARCHS="$(neon_archs)" \
	-DTP=$(TP) \
	-DTS=$(TS) \
	-DLS=$(LS)

ifeq ($(DEB_CROSS),yes)
  ctrl_flags += \
	-DTARGET=$(DEB_TARGET_ARCH) \
	-DLIBUNWIND_BUILD_DEP="$(LIBUNWIND_BUILD_DEP)" \
	-DLIBATOMIC_OPS_BUILD_DEP="$(LIBATOMIC_OPS_BUILD_DEP)"
else
  # add '-DPRI=optional' to ctrl_flags if this is not the default compiler
  # ctrl_flags += \
  #     -DPRI=optional
endif

ifeq ($(with_base_only),yes)
  ctrl_flags += \
	-DBASE_ONLY=yes
endif

control: control-file readme-bugs-file parameters-file copyright-file substvars-file versioned-files

ifeq ($(DEB_CROSS),yes)
  languages = c c++ objc objpp
  addons = libgcc lib64gcc lib32gcc libgomp lib32gomp lib64gomp \
	libcxx lib32cxx lib64cxx libn32cxx cdev c++dev \
	libobjc objcdev objppdev gccxbase
  languages += fortran
  ifeq ($(with_libgfortran),yes)
    addons += fdev libgfortran lib32gfortran lib64gfortran libn32gfortran
  endif
else
  languages = ada c c++ fortran java objc objpp # pascal
  addons = gccbase cdev c++dev fdev libgcj libgcjdev gcjdoc libgnat libs \
	   objcdev source objppdev multilib # libgmath libnof lib64gnat ssp
  ifeq ($(with_libgcc),yes)
    addons += libgcc lib32gcc lib64gcc libn32gcc
  endif
  # 4.5 has libgcc6 on hppa
  addons += lib4gcc
  ifeq ($(with_libcxx),yes)
    addons += libcxx lib32cxx lib64cxx libn32cxx
  endif
  ifeq ($(with_mudflap),yes)
    addons += mudflap
    ifeq ($(with_libmudflap),yes)
      addons += libmudf
    endif
  endif
  ifeq ($(with_libgfortran),yes)
    addons += libgfortran lib32gfortran lib64gfortran libn32gfortran
  endif
  ifeq ($(with_libobjc),yes)
    addons += libobjc lib32objc lib64objc libn32objc
  endif
  ifeq ($(with_libgomp),yes)
    addons += libgomp lib32gomp lib64gomp libn32gomp
  endif
  ifneq (,$(neon_archs))
    addons += libneongcc libneongomp libneonobjc libneongfortran libneoncxx
  endif
  ifeq ($(with_proto),yes)
    addons += proto
  endif
  ifeq ($(with_fixincl),yes)
    addons += fixincl
  endif
  ifeq ($(with_libgcj_doc),yes)
    addons += gcjdoc
  endif
#  ifneq (,$(findstring gtk, $(java_awt_peers)))
#    addons += gtkpeer
#  endif
#  ifneq (,$(findstring qt, $(java_awt_peers)))
#    addons += qtpeer
#  endif
  ifeq ($(with_separate_libgcj),yes)
    ifeq ($(PKGSOURCE),gcc-$(BASE_VERSION))
      languages := $(filter-out java,$(languages))
      addons := $(filter-out gcj libgcj libgcjdev gcjdoc gtkpeer qtpeer,$(addons))
    endif
    ifeq ($(PKGSOURCE),gcj-$(BASE_VERSION))
      languages = java
      addons = gcj libgcj libgcjdev
    ifeq ($(with_libgcj_doc),yes)
      addons += gcjdoc
    endif
#      ifneq (,$(findstring gtk, $(java_awt_peers)))
#        addons += gtkpeer
#      endif
#      ifneq (,$(findstring qt, $(java_awt_peers)))
#        addons += qtpeer
#      endif
      ifeq ($(with_standalone_gcj),yes)
	addons += libgcc lib4gcc lib64gcc lib32gcc libn32gcc
      endif
    endif
  endif
  ifeq ($(with_standalone_gcj),yes)
    ifeq ($(PKGSOURCE),gcj-$(BASE_VERSION))
      ctrl_flags += -DSTANDALONEJAVA
    endif
  endif
  ifeq ($(with_separate_gnat),yes)
    ifeq ($(PKGSOURCE),gcc-$(BASE_VERSION))
      languages := $(filter-out ada,$(languages))
      addons := $(filter-out libgnat,$(addons))
    endif
    ifeq ($(PKGSOURCE),gnat-$(BASE_VERSION))
      languages = ada
      addons = libgnat
    endif
  endif
  ifeq ($(with_separate_gpc),yes)
    ifeq ($(PKGSOURCE),gcc-$(BASE_VERSION))
      languages := $(filter-out pascal,$(languages))
    endif
    ifeq ($(PKGSOURCE),gpc-$(BASE_VERSION))
      languages = pascal
      addons = 
    endif
  endif
  ifeq ($(with_separate_gdc),yes)
    ifeq ($(PKGSOURCE),gcc-$(BASE_VERSION))
      languages := $(filter-out d,$(languages))
    endif
    ifeq ($(PKGSOURCE),gdc-$(BASE_VERSION))
      languages = d
      addons = 
    endif
  endif
  ifneq ($(GFDL_INVARIANT_FREE),yes)
    addons += gfdldoc
  endif
endif

control-file:
	echo "addons: $(addons)"; \
	m4 $(ctrl_flags) \
	  -DPV=$(pkg_ver) \
	  -DCXX_SO=$(CXX_SONAME) \
	  -DGCC_SO=$(GCC_SONAME) \
	  -DOBJC_SO=$(OBJC_SONAME) \
	  -DFORTRAN_SO=$(FORTRAN_SONAME) \
	  -DGCJ_SO=$(PKG_GCJ_EXT) \
	  -DLIBGCJ_EXT=$(PKG_LIBGCJ_EXT) \
	  -DGNAT_SO=$(GNAT_SONAME) \
	  -DGNAT_V=$(GNAT_VERSION) \
	  -DGOMP_SO=$(GOMP_SONAME) \
	  -DGCCMATH_SO=$(GCCMATH_SONAME) \
	  -DMF_SO=$(MUDFLAP_SONAME) \
	  -DSSP_SO=$(SSP_SONAME) \
	  -Denabled_languages="$(languages) $(addons)" \
	  -Dada_no_archs="$(ada_no_archs)" \
	  -Djava_no_archs="$(java_no_archs)" \
	  -Dpascal_no_archs="$(pascal_no_archs)" \
	  -Dfortran_no_archs="$(fortran_no_archs)" \
	  -Dlibgc_no_archs="$(libgc_no_archs)" \
	  -Dcheck_no_archs="$(check_no_archs)" \
	  -Dlocale_no_archs="$(locale_no_archs)" \
	  -Dlinux_gnu_archs="$(linux_gnu_archs)" \
	  -Dbiarch32_archs="$(strip $(subst /, ,$(biarch32archs)))" \
	  -Dbiarch64_archs="$(strip $(subst /, ,$(biarch64archs)))" \
	  -Dbiarchn32_archs="$(strip $(subst /, ,$(biarchn32archs)))" \
		debian/control.m4 > debian/control.tmp2
	uniq debian/control.tmp2 | sed '/^Build/s/ *, */, /g' \
		> debian/control.tmp
	rm -f debian/control.tmp2
	[ -e debian/control ] \
	  && cmp -s debian/control debian/control.tmp \
	  && rm -f debian/control.tmp && exit 0; \
	  mv debian/control.tmp debian/control; touch $(control_stamp)

readme-bugs-file:
	m4 -DDIST=$(distribution) -DSRCNAME=$(PKGSOURCE) \
		debian/README.Bugs.m4 > debian/README.Bugs

copyright-file:
	rm -f debian/copyright
	if echo $(SOURCE_VERSION) | grep -E ^'[0-9]\.[0-9]-[0-9]{8}' ; \
		then SVN_BRANCH="trunk" ; \
	else \
		SVN_BRANCH="gcc-$(subst .,_,$(BASE_VERSION))-branch" ; \
	fi ; \
	sed debian/copyright.in		\
		-e "s/@BV@/$(BASE_VERSION)/g"		\
		-e "s/@SVN_BRANCH@/$$SVN_BRANCH/g"	\
		> debian/copyright

substvars-file:
	rm -f debian/substvars.local.tmp
	( \
		echo 'gcc:Version=$(DEB_GCC_VERSION)'; \
		echo 'gcc:EpochVersion=$(DEB_EVERSION)'; \
		echo 'gcc:SoftVersion=$(DEB_GCC_SOFT_VERSION)'; \
		echo 'gpc:Version=$(DEB_GPC_VERSION)'; \
		echo 'gdc:Version=$(DEB_GDC_VERSION)'; \
		echo 'gcj:Version=$(DEB_GCJ_VERSION)'; \
		echo 'gcj:SoftVersion=$(DEB_GCJ_SOFT_VERSION)'; \
		echo 'gcj:BaseVersion=$(BASE_VERSION)'; \
		echo 'gnat:Version=$(DEB_GNAT_VERSION)'; \
		echo 'binutils:Version=$(BINUTILSV)'; \
		echo 'dep:libgcc=$(LIBGCC_DEP)'; \
		echo 'dep:libgccbiarch=$(LIBGCC_BIARCH_DEP)'; \
		echo 'dep:libcdev=$(LIBC_DEV_DEP)'; \
		echo 'dep:libcbiarch=$(LIBC_BIARCH_DEP)'; \
		echo 'dep:libcbiarchdev=$(LIBC_BIARCH_DEV_DEP)'; \
		echo 'dep:libunwinddev=$(LIBUNWIND_DEV_DEP)'; \
		echo 'dep:libcxxbiarch=$(LIBCXX_BIARCH_DEP)'; \
		echo 'dep:libcxxbiarchdbg=$(LIBCXX_BIARCH_DBG_DEP)'; \
		echo 'dep:libgnat=$(LIBGNAT_DEP)'; \
		echo 'dep:ecj=$(ECJ_DEP)'; \
		echo 'dep:libcloog=$(CLOOG_RUNTIME_DEP)'; \
	) > debian/substvars.local.tmp
ifneq (,$(filter $(DEB_TARGET_ARCH), $(multilib_archs)))
	( \
		echo 'gcc:multilib=gcc-$(BASE_VERSION)-multilib$(TS)'; \
		echo 'gxx:multilib=g++-$(BASE_VERSION)-multilib$(TS)'; \
		echo 'gobjc:multilib=gobjc-$(BASE_VERSION)-multilib$(TS)'; \
		echo 'gobjcxx:multilib=gobjc++-$(BASE_VERSION)-multilib$(TS)'; \
		echo 'gfortran:multilib=gfortran-$(BASE_VERSION)-multilib$(TS)'; \
	) >> debian/substvars.local.tmp
endif
ifeq ($(with_gold),yes)
	echo 'dep:gold=binutils-gold (>= $(BINUTILSV))' \
		>> debian/substvars.local.tmp
endif
ifeq ($(with_libssp),yes)
	echo 'dep:libssp=libssp$(SSP_SONAME) (>= $${gcc:Version})' \
		>> debian/substvars.local.tmp
endif
ifeq ($(with_gomp),yes)
	echo 'dep:libgomp=libgomp$(GOMP_SONAME)$(LS) (>= $${gcc:Version})' \
		>> debian/substvars.local.tmp
endif
ifneq (,$(findstring yes,$(with_lib32fortran) $(with_lib64fortran) $(with_libn32fortran)))
	echo 'dep:libgfortranbiarch=$(libgfortranbiarch)' \
		>> debian/substvars.local.tmp
endif
ifneq (,$(findstring yes,$(with_lib32objc) $(with_lib64objc) $(with_libn32objc)))
	echo 'dep:libobjcbiarch=$(libobjcbiarch)' \
		>> debian/substvars.local.tmp
endif
ifneq (,$(findstring yes,$(with_lib32mudflap) $(with_lib64mudflap) $(with_libn32mudflap)))
	echo 'dep:libmudflapbiarch=$(libmudflapbiarch)' \
		>> debian/substvars.local.tmp
endif
ifneq (,$(findstring yes,$(with_lib32ssp) $(with_lib64ssp) $(with_libn32ssp)))
	echo 'dep:libsspbiarch=$(libsspbiarch)' \
		>> debian/substvars.local.tmp
endif
ifneq (,$(findstring yes,$(with_lib32gomp) $(with_lib64gomp) $(with_libn32gomp)))
	echo 'dep:libgompbiarch=$(libgompbiarch)' \
		>> debian/substvars.local.tmp
endif
ifneq ($(with_standalone_gcj),yes)
  ifeq ($(DEB_HOST_ARCH),armel)
	echo 'dep:gcj=g++$(pkg_ver) (>= $(DEB_GCC_SOFT_VERSION))' \
		>> debian/substvars.local.tmp
  else
	echo 'dep:gcj=gcc$(pkg_ver) (>= $(DEB_GCC_SOFT_VERSION))' \
		>> debian/substvars.local.tmp
  endif
endif
#ifneq (,$(findstring gtk, $(java_awt_peers)))
#	echo 'pkg:gcjgtk=libgcj$(subst 0,,$(GCJ_SONAME))-awt-gtk (>= $(DEB_GCJ_VERSION))' \
#		>> debian/substvars.local.tmp
#endif
#ifneq (,$(findstring qt, $(java_awt_peers)))
#	echo 'pkg:gcjqt=libgcj$(subst 0,,$(GCJ_SONAME))-awt-qt (>= $(DEB_GCJ_VERSION))' \
#		>> debian/substvars.local.tmp
#endif
ifeq ($(DEB_HOST_ARCH),hppa)
	echo 'dep:prctl=prctl' >> debian/substvars.local.tmp
endif
ifneq (,$(filter $(DEB_TARGET_ARCH), powerpc ppc64))
	echo 'base:Replaces=gcc-$(BASE_VERSION)-spu (<< 4.4.0-1)' >> debian/substvars.local.tmp
endif
ifeq ($(distribution)-$(DEB_HOST_ARCH),Debian-amd64)
	echo 'confl:lib32=libc6-i386 (<< 2.9-22)' >> debian/substvars.local.tmp
endif
	[ -e debian/substvars.local ] \
	  && cmp -s debian/substvars.local debian/substvars.local.tmp \
	  && rm -f debian/substvars.local.tmp && exit 0; \
	  mv debian/substvars.local.tmp debian/substvars.local; \
	  touch $(control_stamp)

parameters-file:
	rm -f debian/rules.parameters.tmp
	( \
		echo '# configuration parameters taken from upstream source files'; \
		echo 'GCC_VERSION	:= $(GCC_VERSION)'; \
		echo 'NEXT_GCC_VERSION	:= $(NEXT_GCC_VERSION)'; \
		echo 'BASE_VERSION	:= $(BASE_VERSION)'; \
		echo 'SOURCE_VERSION	:= $(SOURCE_VERSION)'; \
		echo 'DEB_VERSION	:= $(DEB_VERSION)'; \
		echo 'DEB_EVERSION	:= $(DEB_EVERSION)'; \
		echo 'GPC_BASE_VERSION	:= $(GPC_BASE_VERSION)'; \
		echo 'GDC_BASE_VERSION  := $(GDC_BASE_VERSION)'; \
		echo 'DEB_GPC_VERSION	:= $(DEB_GPC_VERSION)'; \
		echo 'DEB_GDC_VERSION	:= $(DEB_GDC_VERSION)'; \
		echo 'DEB_SOVERSION	:= $(DEB_SOVERSION)'; \
		echo 'DEB_SOEVERSION	:= $(DEB_SOEVERSION)'; \
		echo 'DEB_LIBGCC_SOVERSION	:= $(DEB_LIBGCC_SOVERSION)'; \
		echo 'DEB_LIBGCC_VERSION	:= $(DEB_LIBGCC_VERSION)'; \
		echo 'DEB_STDCXX_SOVERSION	:= $(DEB_STDCXX_SOVERSION)'; \
		echo 'DEB_GCJ_SOVERSION	:= $(DEB_GCJ_SOVERSION)'; \
		echo 'PKG_GCJ_EXT	:= $(PKG_GCJ_EXT)'; \
		echo 'PKG_LIBGCJ_EXT	:= $(PKG_LIBGCJ_EXT)'; \
		echo 'DEB_GOMP_SOVERSION	:= $(DEB_GOMP_SOVERSION)'; \
		echo 'DEB_GCCMATH_SOVERSION	:= $(DEB_GCCMATH_SOVERSION)'; \
		echo 'GCC_SONAME	:= $(GCC_SONAME)'; \
		echo 'CXX_SONAME	:= $(CXX_SONAME)'; \
		echo 'FORTRAN_SONAME	:= $(FORTRAN_SONAME)'; \
		echo 'OBJC_SONAME	:= $(OBJC_SONAME)'; \
		echo 'GCJ_SONAME	:= $(GCJ_SONAME)'; \
		echo 'GNAT_VERSION	:= $(GNAT_VERSION)'; \
		echo 'GNAT_SONAME	:= $(GNAT_SONAME)'; \
		echo 'FFI_SONAME	:= $(FFI_SONAME)'; \
		echo 'MUDFLAP_SONAME	:= $(MUDFLAP_SONAME)'; \
		echo 'SSP_SONAME	:= $(SSP_SONAME)'; \
		echo 'GOMP_SONAME	:= $(GOMP_SONAME)'; \
		echo 'GCCMATH_SONAME	:= $(GCCMATH_SONAME)'; \
		echo 'LIBC_DEP		:= $(LIBC_DEP)'; \
	) > debian/rules.parameters.tmp
	[ -e debian/rules.parameters ] \
	  && cmp -s debian/rules.parameters debian/rules.parameters.tmp \
	  && rm -f debian/rules.parameters.tmp && exit 0; \
	  mv debian/rules.parameters.tmp debian/rules.parameters; \
	  touch $(control_stamp)

versioned-files:
	fs=`echo debian/*BV* debian/*GCJ* debian/*CXX* debian/*LC* debian/*MF* | sort -u`; \
	for f in $$fs debian/source.lintian-overrides.in; do \
	  [ -f $$f ] || echo "CANNOT FIND $$f"; \
	  [ -f $$f ] || continue; \
	  f2=$$(echo $$f \
		| sed 's/BV/$(BASE_VERSION)/;s/PV/$(GPC_BASE_VERSION)/;s/CXX/$(CXX_SONAME)/;s/LGCJ/$(PKG_LIBGCJ_EXT)/;s/GCJ/$(PKG_GCJ_EXT)/;s/LC/$(GCC_SONAME)/;s/MF/$(MUDFLAP_SONAME)/;s/\.in$$//'); \
	  sed -e 's/@BV@/$(BASE_VERSION)/g' \
	      -e 's/@PV@/$(GPC_BASE_VERSION)/g' \
	      -e 's/@CXX@/$(CXX_SONAME)/g' \
	      -e 's/@LGCJ@/$(PKG_LIBGCJ_EXT)/g' \
	      -e 's/@GCJ@/$(PKG_GCJ_EXT)/g' \
	      -e 's/@GCJSO@/$(GCJ_SONAME)/g' \
	      -e 's/@LC@/$(GCC_SONAME)/g' \
	      -e 's/@MF@/$(MUDFLAP_SONAME)/g' \
	      -e 's/@SRC@/$(PKGSOURCE)/g' \
	      -e 's/@GFDL@/$(if $(filter yes,$(GFDL_INVARIANT_FREE)),#)/g' \
	      -e 's/@java_priority@/$(java_priority)/g' \
	    $$f > $$f2; \
	  touch -r $$f $$f2; \
	done
